// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
const user = db.collection('user')
const club = db.collection('club')

// 云函数入口函数
exports.main = async (event, context) => {
  var myclubid = []
  var templist =[]
  user.get().then(
    function(res){
    myclubid = res.data[0].myclub
    for (var i = 0; i < myclubid.length; i++) {
      club.where({
        _id: myclubid[i]
      }).get().then(res => {
        templist.push(res.data[0])
      })
    }
      return templist
    }
  )
}